module Stack where

type Stack a = [Maybe a]

push :: Stack a -> a -> Stack a
push s x = [Just x] ++ s

pop :: Stack a -> (Maybe a, Stack a)
pop []     = (Nothing, []) 
pop (x:xs) = (x, xs)

top :: Stack a -> Maybe a
top []     = Nothing
top (x:xs) = x

isEmpty :: Stack a -> Bool
isEmpty s = null s
